import dao.StudentDao;
import impl.StudentDaoImpl;
import model.Student;

import java.util.Scanner;


public class DaoPatternDemo {
    public static void main(String[] args) {
        StudentDao studentDao = new StudentDaoImpl();
        //更改学生信息
        Student student =studentDao.getAllStudents().get(0);
        student.setName("Ann");
        studentDao.updateStudent(student);
        //添加学生
        Scanner sc=new Scanner(System.in);
        System.out.println("输入你要添加学生的信息");
        String name=sc.next();
        int rollno= sc.nextInt();
        student.setName(name);
        student.setRollNo(rollno);
        studentDao.addStudent(student);
        //删除学生信息
        System.out.println("输入你要删除学生的信息");
        String name1=sc.next();
        student.setName(name1);
        studentDao.deleteStudent(student);
        //查找全部学生
        for (Student student2 : studentDao.getAllStudents()) {
            System.out.println("Student: [RollNo : "
                    +student2.getRollNo()+", Name : "+student2.getName()+" ]");
        }
        System.out.println();
        //查找学生
        if(studentDao.getStudent(203)!=null)
        System.out.println("name: [name : "
                +student.getName()+", rollno : "+student.getRollNo()+"]");
        else
            System.out.println("no exit");
    }
}
